<template id="searchBarPhone">
  <div class="content">
    <div class="searchIcon">
      <img src="@/assets/images/mobile_black/home/search.png" />
    </div>
    <div class="searchSelect">
      <div class="currentSelect" @click="openOptions">
        <p class="currentName">{{ selectOptions.current.name }}</p>
        <img :src="dropdownIcon" class="dropdownIcon" />
      </div>
      <div
        class="selectOptions"
        :class="[
          { isShow: selectOptions.isShow && !isInit },
          { isClose: !selectOptions.isShow && !isInit },
        ]"
      >
        <div
          class="selectList"
          v-for="item in selectOptions.list"
          :key="item.value"
          @click="changeValue(item)"
        >
          <p :class="{ isChose: selectOptions.current.value == item.value }">
            {{ item.name }}
          </p>
          <img
            :src="choseIcon"
            class="choseIcon"
            v-if="selectOptions.current.value == item.value"
          />
        </div>
      </div>
    </div>
    <div class="searchInput">
      <input type="text" placeholder="请输入搜索内容" />
    </div>
    <div class="searchBtn">
      查找
    </div>
    <div
      class="downSelectMark"
      :class="[
        { showMark: selectOptions.isShow },
        { closeMark: !selectOptions.isShow },
      ]"
    ></div>
  </div>
</template>

<script>
export default {
  components: {},
  name: "",
  props: {
    selectOptions: {
      type: Object,
    },
  },
  data() {
    return {
      selectIconLeft: require("@/assets/images/mail/types.png"),
      dropdownIcon: require("@/assets/images/mail/dropdown.png"),
      choseIcon: require("@/assets/images/mail/chose.png"),
      isInit: true,
    };
  },
  computed: {},
  methods: {
    //打开选项框
    openOptions() {
      this.isInit = false;
      this.$emit("open", true);
    },
    //更改选项
    changeValue(item) {
      this.$emit("change", item);
    },

    //搜索
    search() {
      this.$emit("search");
    },
  },
  mounted() {},
};
</script>

<style lang="less" scoped>
.content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 30px;
  width: 100%;
  .searchIcon img {
    width: 28px;
    height: 28px;
  }
  .searchSelect {
    position: relative;
    .currentSelect {
      display: flex;
      align-items: center;
      justify-content: space-between;
      min-width: 200px;
      border: 1px solid #999;
      padding: 5px 10px;
      border-radius: 10px;
      .currentName {
        font-size: 24px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #999999;
        margin: 0;
        margin-right: 60px;
      }
      .dropdownIcon {
        width: 18px;
        height: 10px;
      }
    }
    .selectOptions {
      position: absolute;
      top: 50px;
      right: 0;
      z-index: 100;
      width: 100%;
      background: #000;
      box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.2);
      border-radius: 4px;
      padding: 20px 0;
      visibility: hidden;
      .selectList {
        height: 34px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 25px 10px;
        cursor: pointer;

        p {
          font-size: 18px;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: #8e8f8f;
        }

        .choseIcon {
          width: 21px;
          height: 15px;
        }

        .isChose {
          color: #01f5ab;
        }
      }
      .selectList:first-child {
        margin-top: 0;
      }
    }
    .isShow {
      -webkit-animation: fade-in 0.3s cubic-bezier(0.39, 0.575, 0.565, 1) both;
      animation: fade-in 0.3s cubic-bezier(0.39, 0.575, 0.565, 1) both;
      visibility: visible;
      @-webkit-keyframes fade-in {
        0% {
          opacity: 0;
        }

        100% {
          opacity: 1;
        }
      }

      @keyframes fade-in {
        0% {
          opacity: 0;
        }

        100% {
          opacity: 1;
        }
      }
    }

    .isClose {
      -webkit-animation: fade-out 0.3s ease-out both;
      animation: fade-out 0.3s ease-out both;

      @-webkit-keyframes fade-out {
        0% {
          opacity: 1;
        }

        100% {
          opacity: 0;
        }
      }

      @keyframes fade-out {
        0% {
          opacity: 1;
        }

        100% {
          opacity: 0;
          visibility: hidden;
        }
      }
    }
  }
  .searchInput {
    input {
      width: 300px;
      height: 48px;
      background: #343636;
      border-radius: 16px;
      font-size: 14px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #ffffff;
      line-height: 14px;
      border: none;
      padding-left: 39px;
      padding-right: 10px;
    }
    input::-webkit-input-placeholder {
      /* WebKit browsers 适配谷歌 */
      color: rgba(255, 255, 255, 0.5) !important;
    }

    input:-moz-placeholder {
      /* Mozilla Firefox 4 to 18 适配火狐 */
      color: rgba(255, 255, 255, 0.5) !important;
    }

    input::-moz-placeholder {
      /* Mozilla Firefox 19+ 适配火狐 */
      color: rgba(255, 255, 255, 0.5) !important;
    }

    input:-ms-input-placeholder {
      /* Internet Explorer 10+  适配ie*/
      color: rgba(255, 255, 255, 0.5) !important;
    }
  }
  .searchBtn {
    display: flex;
    justify-content: center;
    align-items: center;
    right: 0;
    width: 120px;
    height: 44px;
    border-radius: 4px;
    border: 1px solid #00ffb0;
    backdrop-filter: blur(3px);
    font-size: 24px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #00ffb0;
    line-height: 24px;
    background: none;
  }

  .downSelectMark {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 99;
  }

  .showMark {
    -webkit-animation: fade-in 0.3s cubic-bezier(0.39, 0.575, 0.565, 1) both;
    animation: fade-in 0.3s cubic-bezier(0.39, 0.575, 0.565, 1) both;
    z-index: 99;

    @-webkit-keyframes fade-in {
      0% {
        opacity: 0;
      }

      100% {
        opacity: 1;
      }
    }

    @keyframes fade-in {
      0% {
        opacity: 0;
      }

      100% {
        opacity: 1;
      }
    }
  }

  .closeMark {
    display: none;
    z-index: -1;
    -webkit-animation: fade-out 0.3 ease-out both;
    animation: fade-out 0.3 ease-out both;

    @-webkit-keyframes fade-out {
      0% {
        opacity: 1;
      }

      100% {
        opacity: 0;
      }
    }

    @keyframes fade-out {
      0% {
        opacity: 1;
      }

      100% {
        opacity: 0;
      }
    }
  }
}
</style>
